﻿using HKB.Common;
using HKB.Web.Admin;
using System;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public partial class Admin_Admin_AdminGroup : Admin, IRequiresSessionState
{
    private AdminGroupBll _adminGroup = null;
    protected AdminGroupBll m_adminGroup
    {
        get
        {
            AdminGroupBll adminGroup;
            if (this._adminGroup == null)
            {
                this._adminGroup = new AdminGroupBll(this.conn);
                adminGroup = this._adminGroup;
            }
            else
            {
                adminGroup = this._adminGroup;
            }
            return adminGroup;
        }
    }
    protected DefaultProfile profile
    {
        get
        {
            return (DefaultProfile)this.Context.Profile;
        }
    }
    protected global_asax applicationInstance
    {
        get
        {
            return (global_asax)this.Context.ApplicationInstance;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.admin.CheckSuperAdmin())
        {
            base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "AdminGroup");
            base.WriteRightErrMsg();
        }
        this.BindList();
    }
    protected void BindList()
    {
        this.GridView1.DataSource = this.m_adminGroup.GetAllAdminGroup();
        this.GridView1.DataBind();
    }
    protected void DeleteAdminGroup(object sender, CommandEventArgs e)
    {
        int num = Convert.ToInt32(e.CommandName);
        if (num == 1)
        {
            this.WriteErrMsg("", "分组管理员组不允许删除！", "");
        }
        else
        {
            int adminNumByGroupID = this.m_adminGroup.GetAdminNumByGroupID(num);
            if (adminNumByGroupID > 0)
            {
                this.WriteErrMsg("", "该组下有" + adminNumByGroupID + "个管理员，请先移除！", "");
            }
            this.m_adminGroup.DeleteGroup(num);
            base.WriteLog("Delete", Language.GetAdminMsg("Log/ObjectID", num.ToString()), "AdminGroup");
            this.BindList();
        }
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
        e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
    }
}
